﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="MappingTypeViewModel.cs" >
//   J. Prinz
// </copyright>
// <summary>
//   ViewModel representing an AttributeNameMapping <see cref="AttributeNameMappingType" />  which is used to map a PropertySet <see cref="PropertySetViewModel" />
//   to an Attribute of a SystemUnitClass <see cref="SystemUnitClassViewModel" />
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace AutomationMLMapper.ViewModels.CAEXObjectViewModels
{
    using CAEX_ClassModel;

    /// <summary>
    ///   ViewModel representing an AttributeNameMapping <see cref="AttributeNameMappingType" />  which is used to map a PropertySet <see
    ///    cref="PropertySetViewModel" /> 
    ///   to an Attribute of a SystemUnitClass <see cref="SystemUnitClassViewModel" />
    /// </summary>
    public class MappingTypeViewModel : CAEXObjectViewModel<AttributeNameMappingType>
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="MappingTypeViewModel"/> class. 
        /// </summary>
        /// <param name="mappingObject">
        /// an AttributeNameMapping CAEX-Element 
        /// </param>
        public MappingTypeViewModel(AttributeNameMappingType mappingObject)
            : base(mappingObject)
        {
        }

        #endregion

        #region Public Properties

        /// <summary>
        ///   DisplayName of the CAEX-Element in the UI used in Headers and Labels
        /// </summary>
        public static new string DisplayName
        {
            get
            {
                return "MappingObject";
            }
        }

        /// <summary>
        ///   Name of the SystemUnitClass Attribute in the AttributeNameMapping
        /// </summary>
        public string ClassAttributeName
        {
            get
            {
                return this.CaexObject.SystemUnitAttributeName.Exists()
                           ? this.CaexObject.SystemUnitAttributeName.Value
                           : string.Empty;
            }

            set
            {
                this.CaexObject.SystemUnitAttributeName.Value = value;
            }
        }

        /// <summary>
        ///   Name of the RoleClass Attribute in the AttributeNameMapping
        /// </summary>
        public string RoleAttributeName
        {
            get
            {
                return this.CaexObject.RoleAttributeName.Exists() ? this.CaexObject.RoleAttributeName.Value : string.Empty;
            }

            set
            {
                this.CaexObject.RoleAttributeName.Value = value;
            }
        }

        #endregion
    }
}